import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn } from 'typeorm';

@Entity('sys_order')
export class Order {
    @PrimaryGeneratedColumn({ comment: '订单ID' })
    id: number;

    @Column({ length: 50, unique: true, comment: '订单编号' })
    orderNo: string;

    @Column({ comment: '用户ID' })
    userId: number;

    @Column({ type: 'decimal', precision: 10, scale: 2, comment: '订单总金额' })
    totalAmount: number;

    @Column({ 
        type: 'tinyint',
        default: 0, 
        comment: '订单状态(0-待支付, 1-已支付, 2-已完成, 3-已取消)' 
    })
    status: number;

    @Column({ type: 'json', comment: '订单项列表' })
    orderItems: string;

    @Column({ length: 500, nullable: true, comment: '备注' })
    remark: string;

    @Column({ length: 50, nullable: true, comment: '创建者' })
    createBy: string;

    @CreateDateColumn({ comment: '创建时间' })
    createTime: Date;

    @Column({ length: 50, nullable: true, comment: '更新者' })
    updateBy: string;

    @UpdateDateColumn({ comment: '更新时间' })
    updateTime: Date;

    @Column({ 
        type: 'tinyint',
        default: 0, 
        comment: '删除标志(0-存在, 1-删除)' 
    })
    delFlag: number;
}